// $Header: $
// Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
// ReSharper disable ArrangeModifiersOrder
// ReSharper disable InconsistentNaming
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
using OpcLabs.EasyOpc.DataAccess;
using System;
using OpcLabs.EasyOpc.DataAccess.Extensions;
using OpcLabs.EasyOpc.OperationModel;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
static _Default()
{
// Enable auto-subscribing optimization (not necessary), which can improve performance with repeated Read requests.
Client.TryEnableAutoSubscribingOptimization();
}
// Use a shared client instance to allow for better optimization.
static private readonly EasyDAClient Client = new EasyDAClient();
protected void Page_Load(object sender, EventArgs e)
{
try
{
object value = Client.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single");
TextBox1.Text = value?.ToString() ?? "";
}
catch (OpcException opcException)
{
TextBox1.Text = $"*** {opcException.Message}";
}
}
}
}
' $Header: $
' Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.Extensions
Imports OpcLabs.EasyOpc.OperationModel
' ReSharper disable InconsistentNaming
Partial Public Class _Default
Inherits Page
Shared Sub New()
' Enable auto-subscribing optimization (not necessary), which can improve performance with repeated Read requests.
Client.TryEnableAutoSubscribingOptimization()
End Sub
' Use a shared client instance to allow for better optimization.
Shared ReadOnly Client As New EasyDAClient
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Try
Dim value As Object = Client.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single")
TextBox1.Text = value
Catch opcException As OpcException
TextBox1.Text = $"*** {opcException.Message}"
End Try
End Sub
End Class